package com.aiguigu.sort;

public class BubbleSort {
    public static void main(String[] args) {
        int temp = 0;
        Boolean flag = false;
        int arr[] = {10,14,-1,5,6,55,47};
        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j <arr.length-i-1 ; j++) {
                if (arr[j]>arr[j+1]){
                    flag = true;
                    temp =arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1] = temp;
                }
            }
            if (!flag){
                break;
            }else {
                flag = false;
            }
        }

        for (int i : arr) {
            System.out.println(i+" ");
        }
    }
}
